<?php

abstract class Resource_Backend 
{
    
    /**
    * Return active resource ID. DO NOT force type to INTEGER as returned value 
    * can be NULL in case of parent absence.
    * 
    * @return integer
    */
    static public function active() 
    {
        return Application::getRequest()->get('id')
            ? (int)Application::getRequest()->get('id')
            : self::_default();
    }
    
    /**
    * @desc Return default resource ID. 
    * 
    * @return integer
    */
    static private function _default() 
    {
        if ('add' == Application::getRequest()->get('action')) {
            return null;
        }
        
        $entries = Kernel_Util_Tree::convert(Kernel::factory('Kernel', 'Resource')
            ->menu(Backend_Filter_Structure::get('manager')));
        
        return isset($entries[0]) ? (int)$entries[0]['id'] : null;
    }
    
    /**
    * Return available navigation types.
    * 
    */
    static public function navigationTypes() 
    {
        return array('tree', 'inline', 'hidden');
    }
    
}